<?
require_once ("util/Transformer.php");
require_once ("util/Generator.php");
require_once ("view/MSup/ViewGravarChancelaOperador.php");
require_once ("dao/utilsDAO.php");

class viewMSupRecortarImagemChancelaOperador {
	
	public function show($_REQUEST) {
		
		//ver($_REQUEST, 0, 'RE QUE ST');

		$dest_image = "temp/CHX_".$_REQUEST['PHPSESSID'].".jpg";	
		$image = file_get_contents("temp/CH_".$_REQUEST['PHPSESSID'].".jpg");
		//$image = $image[0];
		
		$margin = 10; // to keep the image and layer in sync
		
		$img = imagecreatetruecolor($_REQUEST['width'], $_REQUEST['height']);
		$org_img = imagecreatefromstring($image); //imagecreatefromjpeg($image);
		//$ims = getimagesize($image);
		$ims[0] = imagesx($org_img);
		$ims[1] = imagesy($org_img);
		imagecopy($img, $org_img, 0, 0, $_REQUEST['tx'], $_REQUEST['ty'], $ims[0], $ims[1]);
		imagejpeg($img, $dest_image, 90);
		imagedestroy($img);
		
       
       $_REQUEST['salvo'] = 'ok';
       
       //ver($_REQUEST,0,"REQUEST DO SALVAR");
       
       $view = new ViewGravarChancelaOperador(); 
       $view->show($_REQUEST);
       
	}
	

}

?>